#!/usr/bin/env bash

apt-get update
apt-get upgrade
apt-get install -y apache2 libapache2-mod-php5 php5
apt-get install -y imagemagick php5-imagick
apt-get install -y vsftpd

a2enmod rewrite

mkdir /var/log/apache2/notmybiz
mkdir /var/log/apache2/notmybiz/frontend
mkdir /var/log/apache2/notmybiz/backend
cp /vagrant/notmybiz /etc/apache2/sites-available
a2ensite notmybiz
a2dissite default

echo 'mysql-server-5.5 mysql-server/root_password password vagrant' | debconf-set-selections
echo 'mysql-server-5.5 mysql-server/root_password_again password vagrant' | debconf-set-selections
apt-get install -y mysql-server-5.5 mysql-client php5-mysql
mysql -uroot -pvagrant -e "CREATE DATABASE IF NOT EXISTS notmybiz; GRANT ALL ON notmybiz.* TO 'notmybiz'@'localhost'; FLUSH PRIVILEGES;"
mysql -uroot -pvagrant notmybiz < /vagrant/notmybiz.sql

service apache2 restart
